﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XrmLibrary.Extensions
{
    public static class StringBuilderExtensions
    {
        /// <summary>
        /// Appends a line to the StringBuilder containing a tabbed key and value pair.
        /// </summary>
        /// <param name="sb">The StringBuilder.</param>
        /// <param name="key">The key.</param>
        /// <param name="val">The value.</param>
        public static void AppendTabbedKeyValueLine(this StringBuilder sb, String key, Object val)
        {
            String line = String.Format("\t{0}: {1}", key, val);
            sb.AppendLine(line);
        }

        /// <summary>
        /// Appends a line to the StringBuilder and allows a format string with arguments.
        /// </summary>
        /// <param name="sb">The sb.</param>
        /// <param name="message">The message.</param>
        /// <param name="args">The args.</param>
        public static void AppendLineFormat(this StringBuilder sb, String message, params Object[] args)
        {
            sb.AppendFormat(String.Format("{0}{1}", Environment.NewLine, message), args);
        }
    }
}
